var e = require;
var t = module;
var n = exports;
("use strict");
var o,
  t =
    (this && this.__extends) ||
    ((o = function (e, t) {
      return (o =
        Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array &&
          function (e, t) {
            e.__proto__ = t;
          }) ||
        function (e, t) {
          for (var n in t)
            Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
        })(e, t);
    }),
    function (e, t) {
      function n() {
        this.constructor = e;
      }
      o(e, t),
        (e.prototype =
          null === t
            ? Object.create(t)
            : ((n.prototype = t.prototype), new n()));
    });
Object.defineProperty(n, "__esModule", { value: !0 }), (n.KS = void 0);
var i,
  t =
    ((i = e("BasePlatform").BasePlatform),
    t(r, i),
    (r.prototype.showRewardAds = function (e) {
      var t = this;
      console.log('ks ad')
      return this.sdk.createRewardedVideoAd? this._config.rewardID ? 
      ((this._rewardAdsCb = e),
            this._rewardAds ||
              ((this._rewardAds = this.sdk.createRewardedVideoAd({
                // adUnitId: "2300012410_01",
                // adUnitId: "2300012505_01",
                adUnitId: "2300012719_01",
              })),
              this._rewardAds.onClose(function () {
                console.log('reward onclose'),
                t._rewardAdsCb(1);
              }),
              this._rewardAds.onReward(function () {
                console.log('reward onreward');
                // 上报
                // window.adShowEvent('reward',"2300012410_01",{ custom_param: "" })
                // if(window.ges){
                // // window.ges.adShowEvent('reward',"2300012410_01",{ custom_param: "" })
                // window.ges.adShowEvent('reward',"2300012410_01","2300012410_01")
                  
                // }
                t._rewardAdsCb(0);
              })),
            void this._rewardAds.show({
              success: function () {
                console.log('reward show success')

              },
              fail: function () {
                console.log('reward show fail')

              },
            }))
          : e(-3)
        : e(-2);
    }),
    (r.prototype.showInsert = function () {
      var t = this;
      console.log('ks idad')

      this.sdk.createInterstitialAd &&
        this._config.insertID &&
        (this._insert ||
          ((this._insert = this.sdk.createInterstitialAd({
            // adUnitId: "2300012410_02",
            // adUnitId: "2300012505_02",
            adUnitId: "2300012719_02",
          })),
          this._insert
            .show()
            .then(function () {})
            .catch(function (e) {
              console.log("[platform] [KSPlatform] showInsert", e);
            }),
          this._insert.onClose(function () {
            t._insert && (t._insert.destroy(), (t._insert = null));
          }),
          this._insert.onError(function (e) {
            console.log("[platform] [KSPlatform] showInsert", e),
              e &&
                1003 == e.errCode &&
                t._insert &&
                (t._insert.destroy(), (t._insert = null));
          })));
    }),
    (r.prototype.shareRecordCap = function (t) {
      var n = this;
      return this._recorder
        ? -1 == this._recordStatus
          ? t(-1)
          : this._recordID
          ? void this._recorder.publishVideo({
              video: this._recordID,
              callback: function (e) {
                e ? ((n._recordStatus = 1), t(1)) : t(0);
              },
            })
          : t(-3)
        : t(-2);
    }),
    (r.prototype.startRecordCap = function () {
      var t = this;
      this.sdk.createMediaRecorder &&
        (this._recorder ||
          ((this._recorder = this.sdk.createMediaRecorder()),
          this._recorder.onStop(function (e) {
            t._recordID = e.videoID;
          }),
          this._recorder.onError(function () {
            t._recordStatus = -1;
          })),
        (this._recordID = null),
        this._recorder.start(),
        (this._recordStatus = 1),
        (this._recordTime = Math.floor(new Date().getTime() / 1e3)));
    }),
    (r.prototype.stopRecordCap = function () {
      this._recorder &&
        1 == this._recordStatus &&
        (this._recorder.stop(),
        (this._recordStatus =
          Math.floor(new Date().getTime() / 1e3) - this._recordTime < 5
            ? -1
            : 0));
    }),
    (r.prototype.getShareStatus = function () {
      return this._recordStatus;
    }),
    r);
function r() {
  var e = i.call(this) || this;
  return (
    (e.sdk = window.kwaigame),
    (e._rewardAds = null),
    (e._rewardAdsCb = null),
    (e._insert = null),
    (e._recorder = null),
    (e._recordStatus = -1),
    (e._recordID = null),
    (e._recordTime = 0),
    console.log("快手"),
    e
  );
}
n.KS = t;
